import { ajax } from '@/utils'

const baseUrl = '/yswy-jdzq-back-service'

export default {
  /** 抵扣券列表 */
  getJdCouponList(data): Promise<any> {
    return ajax.post(`${baseUrl}/coupon/listCoupon`, data)
  },

  /** 抵扣券详情 */
  getJdCouponDetail(id): Promise<any> {
    return ajax.post(`${baseUrl}/coupon/detailCoupon`, { id })
  },

  /** 新增抵扣券 */
  createJdCoupon(data): Promise<any> {
    return ajax.post(`${baseUrl}/coupon/createCoupon`, data)
  },

  /** 编辑抵扣券 */
  editJdCoupon(data): Promise<any> {
    return ajax.post(`${baseUrl}/coupon/editCoupon`, data)
  },

  /** 禁用启用抵扣券 */
  setupJdCoupon(id, status): Promise<any> {
    return ajax.post(`${baseUrl}/coupon/setupCoupon`, { id, status })
  },

  /** 抵扣券发放记录 */
  getListCouponRecord(data): Promise<any> {
    return ajax.post(`${baseUrl}/coupon/listCouponRecord`, data)
  },

  /** 发放抵扣券 */
  sendCoupon(data): Promise<any> {
    return ajax.post(`${baseUrl}/coupon/grantCouponBatchManage`, data)
  },

  /** 导出发放记录 */
  exportCouponRecord(data): Promise<any> {
    return ajax.post(`${baseUrl}/coupon/exportCouponRecord`, data, {
      withResponse: true,
      responseType: 'blob'
    })
  },

  /** 优惠卷选择结构树 */
  getSelectStructure(): Promise<any> {
    return ajax.post(`${baseUrl}/product/couponSelectStructure`)
  }
}
